`for` loop of Microsoft `cmd`: how can I process only the files with a certain extension?
        Posted  
        
            by 
                uvts_cvs
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by uvts_cvs
        
        
        
        Published on 2012-07-02T14:59:56Z
        Indexed on 
            2012/07/02
            15:17 UTC
        
        
        Read the original article
        Hit count: 222
        
I have a the folder c:\test\ and two files in it a.txt and b.txtv.
I would like to process just the files with extension equal to .txt.
If I write this commands
cd c:\test
for %f in (*.txt) do echo %f
I will get the result where both a.txt and b.txtv are listed.
The same happens with
cd c:\test
dir *.txt
It seems .txt is the same of .txtv.
I have Windows XP SP3 in Italian and the result of
ver
is Microsoft Windows XP [Versione 5.1.2600].
The same result is from Windows 7 in English Microsoft Windows XP [Version 6.1.7601].
© Server Fault or respective owner